package com.haoran.dwz.domain.pojo;


import org.hibernate.validator.constraints.NotBlank;

import com.haoran.dwz.common.validator.group.AddGroup;
import com.haoran.dwz.common.validator.group.UpdateGroup;
import com.haoran.dwz.domain.entities.User;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel("用户的注册信息")
public class UserVO {
	
	@ApiModelProperty(value="用户名",position=1)
	@NotBlank(message="用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
	private String username;

	@ApiModelProperty(value="密码",position=2)
	@NotBlank(message="密码不能为空", groups = {AddGroup.class})
    private String password;
    
	@ApiModelProperty(value="密码确认",position=3)
	@NotBlank(message="密码确认不能为空", groups = {AddGroup.class})
    private String pwd;

	@ApiModelProperty(value="注册邮箱",position=4)
	@NotBlank(message="注册邮箱不能为空", groups = {AddGroup.class})
    private String email;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public static User convert(UserVO addedUser) {
		User user = User.withUsername(addedUser.username).password(addedUser.password).build();
		user.setEmail(addedUser.getEmail());
		return user;
	}
}